package edu.psu.collegerecommendationtool.coreservlets;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import edu.psu.collegerecommendationtool.model.CollegeResult;
import edu.psu.collegerecommendationtool.model.UserBean;


@ManagedBean(name="modifyResult")
public class CollegeResultBean {
@ManagedProperty(value="#{userBean}")
   private UserBean user;

   private byte entered_active;

// private String entered_college1;
// private String entered_college2;
// private String entered_college3;
// private String entered_college4;
// private String entered_college5;
   private String entered_result1;
   private String entered_result2;
   private String entered_result3;
   private String entered_result4;
   private String entered_result5;

   private CollegeResult resultList;


   public UserBean getUser() {
      return user;
   }
   public void setUser(UserBean user) {
      this.user = user;
   }

   public byte getEntered_active() {
      return entered_active;
   }
   public void setEntered_active(byte entered_active) {
      this.entered_active = entered_active;
   }

//   public String getEntered_college1() {
//      return entered_college1;
//   }
//   public void setEntered_college1(String entered_college1) {
//      this.entered_college1 = entered_college1;
//   }

//   public String getEntered_college2() {
//      return entered_college2;
//   }
//   public void setEntered_college2(String entered_college2) {
//      this.entered_college2 = entered_college2;
//   }

//   public String getEntered_college3() {
//      return entered_college3;
//   }
//   public void setEntered_college3(String entered_college3) {
//      this.entered_college3 = entered_college3;
//   }

//   public String getEntered_college4() {
//      return entered_college4;
//   }
//   public void setEntered_college4(String entered_college4) {
//      this.entered_college4 = entered_college4;
//   }

//   public String getEntered_college5() {
//      return entered_college5;
//   }
//   public void setEntered_college5(String entered_college5) {
//      this.entered_college5 = entered_college5;
//   }

   public String getEntered_result1() {
      return entered_result1;
   }
   public void setEntered_result1(String entered_result1) {
      this.entered_result1 = entered_result1;
   }

   public String getEntered_result2() {
      return entered_result2;
   }
   public void setEntered_result2(String entered_result2) {
      this.entered_result2 = entered_result2;
   }

   public String getEntered_result3() {
      return entered_result3;
   }
   public void setEntered_result3(String entered_result3) {
      this.entered_result3 = entered_result3;
   }

   public String getEntered_result4() {
      return entered_result4;
   }
   public void setEntered_result4(String entered_result4) {
      this.entered_result4 = entered_result4;
   }

   public String getEntered_result5() {
      return entered_result5;
   }
   public void setEntered_result5(String entered_result5) {
      this.entered_result5 = entered_result5;
   }

   public CollegeResult getResultList() {
      return resultList;
   }
   public void setResultList(CollegeResult resultList) {
      this.resultList = resultList;
   }

////////////////////////////////////////////////////////////////////////

   public String saveResultList() {
      boolean action = false;
      resultList = user.getResultList();

      if ((!entered_result1.equals(resultList.getResult1())) &&
          (!entered_result1.isEmpty())) {
         resultList.setResult1(entered_result1);
         action = true;
      }

      if ((!entered_result2.equals(resultList.getResult2())) &&
          (!entered_result2.isEmpty())) {
         resultList.setResult2(entered_result2);
         action = true;
      }

      if ((!entered_result3.equals(resultList.getResult3())) &&
          (!entered_result3.isEmpty())) {
         resultList.setResult3(entered_result3);
         action = true;
      }

      if ((!entered_result4.equals(resultList.getResult4())) &&
          (!entered_result4.isEmpty())) {
         resultList.setResult4(entered_result4);
         action = true;
      }

      if ((!entered_result5.equals(resultList.getResult5())) &&
          (!entered_result5.isEmpty())) {
         resultList.setResult5(entered_result5);
         action = true;
      }


      if(true == action) {
         user.setResultList(resultList);
         user.saveResultList();
      }

      return ("MainPage");
   }

////////////////////////////////////////////////////////////////////////

   public String generateResultList()
   {
/*
      String name = null;
		
      recommender.createListing(name);
      return null;
*/
	   return null;
   }
}